<template>
  <div class="StudentTable">
    <el-table :data="tableData" style="width: 100%" :stripe="true">
      <!-- Id列 -->
      <el-table-column label="Id">
        <template slot-scope="scope">
          {{ scope.row.id }}
        </template>
      </el-table-column>

      <!-- 类目列 -->
      <el-table-column label="类目">
        <template slot-scope="scope">
          {{ scope.row.LXName }}
        </template>
      </el-table-column>

      <!-- 图片预览列 -->
      <el-table-column label="图片">
        <template slot-scope="scope">
          <img :src="scope.row.LXimages" alt="图片" class="image-preview" />
        </template>
      </el-table-column>

      <!-- 状态列 -->
      <el-table-column label="状态">
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.state"
            :active-value="1"
            :inactive-value="0"
            active-text="使用中"
            inactive-text="已禁止"
            @change="handleStatusChange(scope.row)"
          ></el-switch>
        </template>
      </el-table-column>

      <!-- 操作列 -->
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button @click="handleEdit(scope.row)" type="primary" size="small">
            修改
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {goodslx} from '@/api/pcclinet'
export default {
  name: 'StudentTable',
  data() {
    return {
      tableData: [
      ]
    }
  },
  mounted() {
    this.goodslx()
  },
  methods: {
    handleStatusChange(row) {
      //  console.log(`状态已更改为: ${row.state === 1 ? '使用中' : '已禁止'}`);
    },
    goodslx(){
      goodslx().then(res=>{
        this.tableData=res.data.goodlx
      })
    
    }
  }
}
</script>

<style lang="scss" scoped>
.image-preview {
  max-width: 100px;
  max-height: 100px;
}
</style>
